package com.tingyuge.base.thread.wang.chapter4;

/**
 * Created by xiaodao
 * date: 2019/11/28
 */
public class DeamonThread {
    public static void main(String[] args) {
        Thread r = new Thread(){
            @Override
            public void run() {
                try {
                    System.out.println(Thread.currentThread().getName()+" running");
                    Thread.sleep(1000);
                    System.out.println(Thread.currentThread().getName()+" done");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }; //new

        //runnable->running->dead->blocked
        r.setDaemon(true);
        r.start();

        try {
            Thread.sleep(10*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName());
    }
}
